<div id="tb<{$uniqid}>" style="padding:5px">
<form id="newsaddfm" method="post" enctype="multipart/form-data">
<table border="0" width="100%" cellspacing="1" cellpadding="5" bgcolor="#c4d3e1" style="text-align:left; line-height:18px;">
		<tr bgcolor="#FFFFFF"> 
			<td style="line-height:30px;"  width="10%">标题：</td>
			<td colspan="5" width="90%"><input name="title" type="text" style="width:400px;" class="textbox-text validatebox-text textbox-prompt easyui-validatebox" placeholder="请输入标题."  required="true"></td>
		</tr>
		<tr bgcolor="#FFFFFF"> 
			<td class="main" >栏目:</td>
			<td class="main" >			
			<SELECT name='newsclass_id' size='1' required="true">
			<?php foreach($newsclass as $k=>$v):?>
			<OPTION value="<?php echo $v->id;?>"><?php echo $v->title;?></OPTION>
				<?php foreach($v->children as $k1=>$v1):?>
				<OPTION value="<?php echo $v1->id;?>">&nbsp;&nbsp;|--<?php echo $v1->title;?></OPTION>
				<?php endforeach;?>
			<?php endforeach;?>
			</SELECT>
			</td>
			<td style="line-height:30px;">关键词：</td>
			<td colspan="3"><input name="keywords" type="text" style="width:400px;"  class="textbox-text validatebox-text textbox-prompt easyui-validatebox" placeholder="请输入关键词"></td>
		</tr>		
		<tr bgcolor="#FFFFFF"> 
			<td class="main">作者:</td>
			<td class="main"><input type="text" size="20" name="author" class="textbox-text validatebox-text textbox-prompt easyui-validatebox"  placeholder="请输入作者" value=""></td>
			
			<td class="main">来源:</td>
			<td><input type="text" size="20" name="copyfrom" class="textbox-text validatebox-text textbox-prompt easyui-validatebox"  placeholder="请输入来源"  value=""></td>
			
			<td>来源网址：</td>
			<td><input type="text" size="45" class="textbox-text validatebox-text textbox-prompt easyui-validatebox"  placeholder="请输入来源网址"  name="copyfromurl" value=""></td>
		</tr>
		<tr bgcolor="#FFFFFF"> 
			<td class="main">排序：</td>
			<td class="main"><input type="text" name="sortorder" size="20"  class="textbox-text validatebox-text textbox-prompt easyui-validatebox"   value="500" /></td>						 			<td style="line-height:30px;">状态：</td>
			<td><label><input name="status" type="checkbox" class="textbox-prompt" value="1" checked="checked" >激活</label></td>		
			<td class="main">推荐：</td>
			<td class="main"><label><input type="checkbox" name="recommend" class="textbox-prompt"  value="1" />设为推荐</label></td>						 
		</tr>
		<tr bgcolor="#FFFFFF"> 
			<td class="main">缩略图:</td>
			<td class="main" colspan="5">
			<span id="newsaddlogo"></span>
			<a href="javascript:;" class="a-upload l-btn"><input type="file" id="newsaddupfile" name="upfile" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" onchange="html5ReaderNewsadd()">点击这里上传缩略图</a>
			<script>
				function html5ReaderNewsadd() {
					var simpleFile = document.getElementById("newsaddupfile").files[0];
					if(!/image\/\w+/.test(simpleFile.type)) {
						alert("请确保文件类型为图像类型");
						return false;
					}
					var reader = new FileReader();
					reader.readAsBinaryString(simpleFile);
					reader.onload = function(f){
						var result = document.getElementById("newsaddlogo");
						var src = "data:" + simpleFile.type + ";base64," + window.btoa(this.result);
						result.innerHTML = '<img style= "max-height:80px" src ="'+src+'"/>';
					}
				}
			</script>
			</td>
		</tr>
		
		
		<tr bgcolor="#FFFFFF"> 
			<td style="line-height:30px;">内容：</td>
			<td colspan="5">
			<script id="newsaddEditor" name="content" type="text/plain"></script>
			</td>
		</tr>
		<tr> 
			<td colspan="6" bgcolor="#F4F4F4" style="border-top:#ddd 1px solid;text-align:right; padding-right:25px;">			
			<div>
			<a href="javascript:;" class="l-btn l-btn-small" onclick="newsaddsubmitForm()"><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">保存</span><span class="l-btn-icon icon-ok">&nbsp;</span></span></a>
			<a href="javascript:;" class="l-btn l-btn-small" onclick="newsaddclearForm()"><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">关闭</span><span class="l-btn-icon icon-no">&nbsp;</span></span></a>
			</div>
			</td>			
		</tr>
</table>
</form>
</div>

<script>
/***关闭umeditor BOF***/
if(typeof(newsaddum)!='undefined'){
		 newsaddum.destroy();
}
/***关闭umeditor EOF***/
var newsaddum = UE.getEditor('newsaddEditor');
var newsaddclearForm=function(){
	$('#newsaddfm').form('clear');
	$('#rightTabs').tabs('close','添加文章');
}
var newsaddsubmitForm=function(){
	$('#newsaddfm').form('submit', {    
			url:'/merchant/news/newsincrease',    
			success: function(data){    
				var data = eval('(' + data + ')');
				
				if(data.code=='200'){
						$.messager.show({
								title:'提示',
								msg:data.msg,
								timeout:3000,
								showType:'slide'
						});				
						$('#newsaddfm').form('clear');
						if(typeof($("#news"))!='undefined') $("#news").datagrid('reload');
						$('#rightTabs').tabs('close','添加文章');						
				}else{
						$.messager.alert('提示',data.msg,'warning');
				}
			}
	});
}
</script>
